<!DOCTYPE html>
<html>
<head>
	<meta charset="UTF-8">
	<title>コントロールパネル</title>

    <link href="./assets/styles/default.css" rel="stylesheet" />
	<script src="./assets/scripts/libs/jquery-1.7.1.min.js" type="text/javascript"></script>
	<script src="./assets/scripts/import.js" type="text/javascript"></script>

	<style>
		.tLeft {
			clear: both;
			float:left;width:48%;
		}
		.tRight {
			float:right;width:48%;
		}
		h5 {
			padding:10px;
			margin: 0;
			text-align: left;
			background-color: #f5f5f5;
			border-bottom: 3px double #e5e5e5;
			font-size: 14px;
		}
		#totalTable th {
			text-align: right !important;
		}

	</style>
	<script type="text/javascript">
//	function check(tableid)
//	{
//		var ret=true;
//		//checkempty
//		if(tableid=="t1"||tableid=="t2"||tableid=="t3"||tableid=="t4")
//		{
//			$("#"+tableid+" input:text").each(
//					function(i,el){
//						if($(this).val()=="")
//						{
//							alert("入力してください");
//							$(this).focus();ret=false;return false;
//						}
//					}
//			);
//		}
//		if(!ret) return ret;

//		//checknumbers
//		if(tableid=="t3"||tableid=="t4")
//		{
//			$("#"+tableid+" input[chk='num']").each(
//					function(i,el){
//						if(!$.isNumeric($(this).val()))
//						{
//							alert("半角整数で入力してください");
//							$(this).focus();ret=false;return false;
//						}
//					}
//			);
//		}
//			if(!ret) return ret;

//		//checkdate
//		if(tableid=="t5")
//		{
//			$("#"+tableid+" input[chk='date']").each(
//					function(i,el){
//						if(!isDate($(this).val()))
//						{
//							alert("YYYY-MM-DD で入力してください");
//							$(this).focus();ret=false;return false;
//						}
//					}
//			);
//		}


//		return ret
//	}

//	function checkall()
//	{
//		if(!check("t1"))return false;
//		if(!check("t2"))return false;
//		if(!check("t3"))return false;
//		if(!check("t4"))return false;
//		if(!check("t5"))return false;
//		if(!check("t6"))return false;s
//		return false;
//	}

//	function isDate(value){
//		var ereg = /^(\d{1,4})(-|\/)(\d{1,2})(-|\/)(\d{1,2}) {1,10}(0\d{1}|1\d{1}|2[0-3]):[0-5]\d{1}:([0-5]\d{1})$/;
//		var r = value.match(ereg);
//		if (r == null) {
//		return false;
//		}
//		var d = new Date(r[1], r[3] - 1, r[5]);
//		var result = (d.getFullYear() == r[1] && (d.getMonth() + 1) == r[3] && d.getDate() == r[5]);
//		return result;
//}


	    $(function () {
	        $('#btn_update').unbind();
	        $('#btn_updatestatus').unbind().click(function (e) {
	            customConfirm('更新してよろしいですか？', "", $(this), function () {
	                loading();
	                //pushID();
	                //$('input[name=mode]', form).val('input');
	                $('form').submit();
	            });

	        });
	    });
	</script>
</head>
<body>

{{$zhead}}
<div id="container">
{{$zmenu}}

<center><span style="color:red;">{{$errmsg}}</span></center>
    <article>
    	<h2><span>&nbsp;</span>注文管理<p><a href="javascript:;">Open Plugins</a></p></h2>
        <nav>
        	<ul>
				<li class="active"><a href="Home_OrderManage_index.html"><span>履歴検索</span></a></li>
				<li><a href="Home_order_summary.html"><span>売上集計</span></a></li>
				<li><a href="Home_order_setting.html"><span>基本設定</span></a></li>
			</ul>
        </nav>
		<section id="content">
			<h3>注文情報参照</h3>
			<ul class="clear btns float-right t10 b10" style="position:relative;top: 5px;right: -15px;">
				<li class="btn single c"><a href="{{'Home/OrderManage/index'|U}}" >戻る</a></li>
			</ul>
			
		
				<h4>
					<span>&nbsp;</span>
					注文No.{{$orderrow.order_number}}
					&nbsp;&nbsp;
					{{$orderrow.order_time|date_format:"%Y/%m/%d %H:%M:%S"}}
				</h4>

				<ul class="clear btns float-right t10 b10" style="position:relative;right: -15px;">
					<li class="btn left c"><a href="javascript:" onclick="$('#fm').attr('action','{{'Home/OrderRefer/openupdatesended'|U}}');$('#fm').submit();">配送完了</a></li>
					<li class="btn right c"><a  onclick="$('#fm').attr('action','{{'Home/OrderRefer/updatedelete'|U}}');$('#fm').submit();">削除</a></li>
				</ul>

				<div class="tLeft">
					<h5>注文基本情報</h5>
					<table class="formTable">
						<tbody>
							<tr>
								<th>注文日時</th>
								<td colspan="2">{{$orderrow.order_time|date_format:"%Y/%m/%d %H:%M:%S"}}</td>
							</tr>
							<tr>
								<th>注文番号</th>
								<td colspan="2">{{$orderrow.order_number}}</td>
							</tr>
							<tr>
								<th>状態</th>
								<td align="left">
                                <form name="fm" id="fm" action="{{'Home/OrderRefer/updatestatus'|U}}" method="post" enctype="multipart/form-data" class="clear">
                                	<input name="order_id" type="hidden" value="{{$orderrow.order_id}}">
                                <select name="order_status" class="float-left">
                                <option value="1" {{if $orderrow.order_status eq 1}}selected{{/if}}>未確定</option>
                                <option value="2" {{if $orderrow.order_status eq 2}}selected{{/if}}>確定</option>
                                <option value="3" {{if $orderrow.order_status eq 3}}selected{{/if}}>発送済</option>
                                <option value="4" {{if $orderrow.order_status eq 4}}selected{{/if}}>キャンセル</option>
                                </select>
                                </td>
                                <td>
                      <ul class="clear btns float-left" >
							    <li class="btn single c"><a id="btn_updatestatus" href="javascript:" >更新</a></li>
                               </ul>
                            	</form>

	
                                </td>
							</tr>
							<tr>
								<th>経路</th>
								<td colspan="2">{{if $orderrow.order_way eq 1}}PC{{elseif $orderrow.order_way eq 2}}スマホ{{/if}}</td>
							</tr>
						</tbody>
					</table>
					<h5>
						請求住所
						<ul class="clear btns float-right" style="position:relative;top: -5px">
							<li class="btn single c"><a href="javascript:" onclick="$('#fm').attr('action','{{'Home/OrderRefer/openupdaterequestaddress'|U}}');$('#fm').submit();">更新</a></li>
						</ul>
					</h5>
					<table class="formTable" id="t1">
						<tbody>
							<tr>
								<th>氏名</th>
								<td>{{$orderrow.user_name1}}
								{{$orderrow.user_name2}}</td>
							</tr>
							<tr>
								<th>貴医院名・貴技工所名</th>
								<td>{{$orderrow.user_office_name}}</td>
							</tr>
							<tr>
								<th>住所</th>
								<td>
								{{$orderrow.user_local_name}}
								{{$orderrow.user_treet_name}}
								{{$orderrow.user_address}}
								</td>
							</tr>
							<tr>
								<th>電話番号</th>
								<td>{{$orderrow.user_tel_number}}</td>
							</tr>
							<tr>
								<th>E-Mail</th>
								<td>{{$orderrow.email}}</td>
							</tr>
						</tbody>
					</table>
					<h5>支払方法</h5>
					<table class="formTable">
						<tbody>
							<tr>
								<th>支払方法</th>
								<td>{{$orderrow.pay_content}}</td>
							</tr>
							<tr>
								<th>与信情報</th>
								<td>{{$orderrow.payinfo}}</td>
							</tr>
						</tbody>
					</table>
				</div>

				<div class="tRight">
					<h5>会員情報</h5>
					<table class="formTable">
						<tbody>
							<tr>
								<th>会員氏名</th>
								<td>
								{{$userrow.user_name1|cat:'&nbsp'|cat:$userrow.user_name2}}
								</td>
							</tr>
							<tr>
								<th>貴医院名・貴技工所名</th>
								<td>{{$userrow.workshop_name}}</td>
							</tr>
							<tr>
								<th>E-Mail</th>
								<td>{{$userrow.email}}</td>
							</tr>
							<tr>
								<th>グループ</th>
								<td></td>
							</tr>
						</tbody>
					</table>
					<h5>
						配送住所
						<ul class="clear btns float-right" style="position:relative;top: -5px">
							<li class="btn single c"><a href="javascript:" onclick="$('#fm').attr('action','{{'Home/OrderRefer/openupdatesendaddress'|U}}');$('#fm').submit();">更新</a></li>
						</ul>
					</h5>
					<table class="formTable" id="t2">
						<tbody>
							<tr>
								<th>氏名</th>
								<td>
								{{$orderrow.send_name1}}
								{{$orderrow.send_name2}}
								</td>
							</tr>
							<tr>
								<th>貴医院名・貴技工所名</th>
								<td>{{$orderrow.send_office_name}}</td>
							</tr>
							<tr>
								<th>住所</th>
								<td>
								{{$orderrow.send_local_name}}
								{{$orderrow.send_treet_name}}
								{{$orderrow.send_address}}
								</td>
							</tr>
							<tr>
								<th>電話番号</th>
								<td>{{$orderrow.send_tel_number}}</td>
							</tr>
						</tbody>
					</table>
					<h5>
						配送情報
						<ul class="clear btns float-right" style="position:relative;top: -5px">
							<li class="btn single c"><a href="javascript:" onclick="$('#fm').attr('action','{{'Home/OrderRefer/openupdatesended'|U}}');$('#fm').submit();">配送完了</a></li>
						</ul>
					</h5>
					<table class="formTable" id="t5">
						<tbody>
							<tr>
								<th>配送日</th>
								<td>{{$orderrow.sent_datetime|date_format:"%Y/%m/%d"}}</td>
							</tr>
							<tr>
								<th>配送会社</th>
								<td>{{$orderrow.delivery_company}}</td>
							</tr>
							<tr>
								<th>伝票番号</th>
								<td>{{$orderrow.delivery_number}}</td>
							</tr>
							<tr>
								<th>コメント</th>
								<td>{{$orderrow.delivery_app}}</td>
							</tr>
						</tbody>
					</table>
				</div>

				<h4 class="clear">
					<span>&nbsp;</span>注文情報
					<ul class="clear btns float-right" style="position:relative;top: -25px">
						<li class="btn single c"><a href="javascript:" onclick="$('#fm').attr('action','{{'Home/OrderRefer/openupdategoods'|U}}');$('#fm').submit();">更新</a></li>
					</ul>
				</h4>

				<table id="search_result" class="sortable" style="margin-bottom: 20px;">
					<thead>
						<tr>
							<th class="align-center">商品情報＜コード＞</th>
							<th>単価</th>
							<th>数量</th>
							<th>個別送料</th>
							<th>小計</th>
						</tr>

					</thead>
					<tbody id="t3">
					<input name="goodcount" type="hidden" value="{{$goods|@count}}">
					{{foreach name=goodloop from=$goods item=i}}
						<tr ><input name= "goodid_{{$smarty.foreach.goodloop.index}}" type="hidden" value="{{$i.id}}">
							<td>{{$i.goods_name}}＜{{$i.goods_id}}＞</td>
							<td>\{{$i.goods_unitprice|number_format}}</td>
							<td>\{{$i.goods_num}}</td>
							<td>\{{$i.send_price|number_format}}</td>
							<td>\{{$i.goods_unitprice*$i.goods_num+$i.send_price|number_format}}</td>
						</tr>
					{{/foreach}}
					</tbody>
				</table>

				<div class="tLeft">
					<h5>
						その他
						<ul class="clear btns float-right" style="position:relative;top: -5px">
							<li class="btn single c"><a href="javascript:" onclick="$('#fm').attr('action','{{'Home/OrderRefer/openupdateothers'|U}}');$('#fm').submit();">更新</a></li>
						</ul>
					</h5>
					<table class="formTable">
						<tbody>
							<tr>
								<th>注文コメント</th>
								<td>{{$orderrow.order_appraise}}</td>
							</tr>
							<tr>
								<th>社内コメント</th>
								<td>{{$orderrow.insideappraise}}</td>
							</tr>
						</tbody>
					</table>
				</div>

				<div class="tRight">
					<h5>
						注文合計
						<ul class="clear btns float-right" style="position:relative;top: -5px">
							<li class="btn single c"><a href="javascript:" onclick="$('#fm').attr('action','{{'Home/OrderRefer/openupdatesumprice'|U}}');$('#fm').submit();">更新</a></li>
						</ul>
					</h5>
					<table class="formTable" id="totalTable" >
						<tbody id="t4">
							<tr>
								<th>合計金額</th>
								<td class="align-right">\{{$orderrow.goods_sum|number_format}}</td>
							</tr>
							<tr>
								<th>送料</th>
								<td class="align-right">\{{$orderrow.send_price|number_format}}</td>
							</tr>
							<tr>
								<th>手数料</th>
								<td class="align-right">\{{$orderrow.buying_price|number_format}}</td>
							</tr>
							<tr>
								<th>税込</th>
								<td class="align-right">\{{$orderrow.tax|number_format}}</td>
							</tr>
							<tr>
								<th>総合計</th>
								<td class="align-right">\{{$orderrow.all_sum|number_format}}</td>
							</tr>
						</tbody>
					</table>
				</div>

				<p class="button">
					<button type="button" id="btn_update" class="submit" onclick="location.reload()"><span>更新</span></button>
				</p>
		
		</section>
	</article>
</div>
<footer id="dashboard_footer">Copyright (C) SHIFT. / All rights reserved.</footer>
</body>
</html>